package com.aishang.shopback_2005.service.impl;

import com.aishang.shopback_2005.dao.OrderitemMapper;
import com.aishang.shopback_2005.dao.OrdersMapper;
import com.aishang.shopback_2005.po.Orderitem;
import com.aishang.shopback_2005.po.Orders;
import com.aishang.shopback_2005.po.OrdersExt;
import com.aishang.shopback_2005.po.Product;
import com.aishang.shopback_2005.service.OrderService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class OrderServiceImpl implements OrderService {
    @Resource
    private OrdersMapper ordersMapper;
    @Resource
    private OrderitemMapper orderitemMapper;
    @Override
    public PageInfo<Orders> getAllOrders(OrdersExt ordersExt) {
        //设置pageNow和pageSize
        PageHelper.startPage(ordersExt.getPageNow(),8);
        //查询订单集合
        List<Orders> ordersList=ordersMapper.getAllOrders(ordersExt);
        PageInfo<Orders> ordersPageInfo= new PageInfo<Orders>(ordersList,7);
        return ordersPageInfo;
    }

    @Override
    public List<Orderitem> getProductByOid(Integer oid) {

        return orderitemMapper.getProductByOid(oid);
    }

    @Override
    public void updateOrders(Orders orders) {
        ordersMapper.updateOrders(orders);
    }
}
